package com.hongxun.design.activitys;

import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.text.method.ScrollingMovementMethod;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.alibaba.fastjson.JSON;
import com.baidu.mapapi.map.BaiduMap;
import com.baidu.mapapi.map.MapStatus;
import com.baidu.mapapi.map.MapStatusUpdateFactory;
import com.baidu.mapapi.map.MapView;
import com.baidu.mapapi.map.OverlayOptions;
import com.baidu.mapapi.map.Polyline;
import com.baidu.mapapi.map.PolylineOptions;
import com.baidu.mapapi.model.LatLng;
import com.facebook.drawee.view.SimpleDraweeView;
import com.hongxun.design.MyApp;
import com.hongxun.design.R;
import com.hongxun.design.bean.Exploration;
import com.hongxun.design.bean.PointSumBean;
import com.hongxun.design.bean.PointSumRouteBean;
import com.hongxun.design.bean.ProjectItemBean;
import com.hongxun.design.bean.SpanBean;
import com.hongxun.design.bean.photopassbean.SystemTypeBean;
import com.hongxun.design.interfaces.HeadSecond;
import com.hongxun.design.interfaces.UpdateMap;
import com.hongxun.design.listeners.ListenerSet;
import com.hongxun.design.listeners.MyLocationListenner;
import com.hongxun.design.mytools.IconSourse;
import com.hongxun.design.mytools.IntentToActivity;
import com.hongxun.design.mytools.MString;
import com.hongxun.design.mytools.MyLog;
import com.hongxun.design.mytools.SetTypeface;
import com.hongxun.design.mytools.ToastShow;
import com.hongxun.design.ui.MBaiduMap;
import com.hongxun.design.ui.dialogstyle.MyDialog;
import com.hongxun.design.ui.headandbottonpanel.HeadSecondControlPanel;
import com.hongxun.design.ui.titlepopupwindow.BitTypeBean;
import com.hongxun.design.utils.DataUtil;
import com.hongxun.design.utils.PopwindowUtil;
import com.hongxun.design.utils.fastjson.FastJsonUtil;
import com.hongxun.design.utils.fileutil.GetFileUtil;
import com.hongxun.design.utils.fileutil.SetFileUtil;
import com.hongxun.design.utils.httputil.HttpStringCodeTableUtil;
import com.hongxun.design.utils.httputil.HttpStringUtil;
import com.hongxun.design.utils.imageutil.UriUtil;
import com.hongxun.design.utils.maputil.NavigationUtil;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

/**
 * Created by zerdoor_pc on 2016/6/2.
 * 项目首页地图
 */
public class ProjectMapActivity extends BaseActivity implements HeadSecond, UpdateMap {
    public static String projectName;
    public static String projectType = "11";
    //ProjectItemBean projectBean;
    //SearchProjectBean searchProjectBean;
    TextView words;
    //String type;
    public static List<BitTypeBean> bitTypeBeans = new ArrayList<>();
    String stage = "";
    HeadSecondControlPanel headsecond_layout;
    PointSumBean bean;
    List<Exploration> transList;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
//        SDKInitializer.initialize(getApplicationContext());
        setContentView(R.layout.activity_projectmap);
        ProjectItemBean info = FastJsonUtil.JsonToGetProject(GetFileUtil.getProjectInfo());
        MyApp.currProject.setBeanWithNo(info);
        findBar();
        findView();
        initialization();
    }

    private void getIntentData() {
        projectName = MyApp.currProject.getProject_name();
        try {
            currentPt = new LatLng(Double.parseDouble(MyApp.currProject.getLat()), Double.parseDouble(MyApp.currProject.getLng()));
        } catch (Exception e) {
        }
        stage = getDesignStage(MyApp.currProject.getStage());
        projectType = MyApp.currProject.getProject_type();
        MyApp.currProject.setProject_name(projectName);
    }


    @Override
    public void findBar() {
        getIntentData();
        headsecond_layout = (HeadSecondControlPanel) findViewById(R.id.projectmap_layout);
        headsecond_layout.initHeadPanel(DataUtil.getsecondbean("", View.VISIBLE, R.color.login_yellow,
                ListenerSet.back, projectName, R.color.title, View.VISIBLE, IconSourse.BACK + "", View.VISIBLE));
        SetTypeface.set(headsecond_layout.mRightTitle, IconSourse.DAOHANG);
        headsecond_layout.mRightTitle.append(" 导航");
        headsecond_layout.setClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (MyApp.bdLocation != null) {
                    Navigation();
                } else {
                    ToastShow.showShort(mActivity, "获取当前位置！");
                    inItLocation();
                }
            }
        });
    }

    /**
     * 开启定位图层*
     */
    private void inItLocation() {
        //
        mBaiduMap.setMyLocationEnabled(true);
        MyLocationListenner myListener = MyLocationListenner.getint(mMapView, this);
        myListener.setIsFirstLoc(true);
        myListener.setIsLocal(true);

    }

    @Override
    public void updateMapState(LatLng currentPt) {
        Navigation();
    }

    /**
     * 开启导航*
     */
    private void Navigation() {
        if (MyApp.bdLocation == null) {
            ToastShow.showShort(mActivity, "定位失败！");
            return;
        } else if (MyApp.currProject.getLat().length() == 0 || MyApp.currProject.getLng().length() == 0) {
            ToastShow.showShort(mActivity, "获取项目位置失败！");
            return;
        } else {
            ToastShow.showShort(mActivity, "正在启动导航！");
            MyLog.L(MString.SUCCESSED + " 开始位置：" + MyApp.bdLocation.getLatitude() + "----" + MyApp.bdLocation.getLongitude());
            MyLog.L(MString.SUCCESSED + " 结束位置：" + Double.parseDouble(MyApp.currProject.getLat()) + "----" + Double.parseDouble(MyApp.currProject.getLng()));
//            NavigationUtil.startNavi(this, new LatLng(MyApp.bdLocation.getLatitude(), MyApp.bdLocation.getLongitude()), new LatLng(Double.parseDouble(MyApp.currProject.getLat()), Double.parseDouble("104.0998029")), "", "");
            NavigationUtil.startNavi(this, new LatLng(MyApp.bdLocation.getLatitude(), MyApp.bdLocation.getLongitude()), new LatLng(Double.parseDouble(MyApp.currProject.getLat()), Double.parseDouble(MyApp.currProject.getLng())), MyApp.bdLocation.getAddrStr(), MyApp.currProject.getProject_name());
        }
    }

    boolean isfirstin = true;

    @Override
    protected void onResume() {
        if (baidumapstyle != null) baidumapstyle.onResume();
        MyApp.ChangeToOldProject();
        MyApp.currExploration.clear();
        MyApp.activity = this;
        mActivity = this;
        /**返回刷新**/
        if (!isfirstin) {
            MyApp.HTTP.http.isLoad = false;
            getpointSum();//获取项目详情信息
            getTransformerList();//获取台区
            if (buldeflag) {
                getExplorationList("12");
            } else {
                getExplorationList("11");
            }
            TextView pop_title = (TextView) findViewById(R.id.projectmap_pop_title);
            pop_title.setText("台区");
        } else {
            isfirstin = false;
        }
        headsecond_layout.setTitle(MyApp.currProject.getProject_name());

        super.onResume();
    }

    @Override
    protected void onPause() {
        if (baidumapstyle != null) baidumapstyle.onPause();
        super.onPause();
    }


    @Override
    protected void onDestroy() {
        if (baidumapstyle != null) baidumapstyle.onDestroy();
        super.onDestroy();
    }

    @Override
    protected void findView() {
        super.findView();
        findViewAndInit_UI();
        findView_Data();
        findViewAndInit_MapButton();//初始化地图位置
    }

    @Override
    protected void initialization() {
        super.initialization();
        if (pointSumHandler == null) addPointSumHandler();
        if (transformerListHandler == null) addTransformerListHandler();
        addPointHandler();

        if (MyApp.isOnLine) {
            getpointSum();//获取项目详情信息
            getTransformerList();//获取台区

        } else {
            /**读取缓存**/
            bean = GetFileUtil.getPointSum();
            pointSumHandler.sendEmptyMessage(1);
            transList = GetFileUtil.getTransformerLis();
            transformerListHandler.sendEmptyMessage(2);
        }
        isnewlyBuild(null);

    }

    public void openCode(View v) {
        MyDialog.openCodeImage(mActivity, JSON.toJSONString(MyApp.currProject));
    }

    /**
     * *************************************数据请求*****************************************************************
     */
    /**
     * 获取项目详情信息*
     */
    private void getpointSum() {
        if (MyApp.isOnLine) {
            MyApp.HTTP.getPointSum(pointSumHandler, HttpStringUtil.SUCCESSED, MyApp.currProject.getStage_id(), "");
        } else {
        }
    }

    /**
     * 获取台区*
     */
    private void getTransformerList() {
        if (MyApp.isOnLine) {
            MyApp.HTTP.getTransformerList(transformerListHandler, HttpStringUtil.SUCCESSED, MyApp.currProject.getStage_id());
        } else {
            transList = GetFileUtil.getTransformerLis();
            transformerListHandler.sendEmptyMessage(2);
        }
    }

    /**
     * 获取点位列表*
     */
    private void getExplorationList(String projectType) {
        pointType = projectType;
        if (MyApp.isOnLine) {
            MyApp.HTTP.getExplorationList(pointHandler, HttpStringUtil.SUCCESSED, projectType, MyApp.currProject.getStage_id(), "");//获取踏勘点列表
        } else {
            if (pointData == null) {
                pointData = GetFileUtil.getExplorationList(projectType);
            } else {
                pointData.clear();
                pointData.addAll(GetFileUtil.getExplorationList(projectType));
            }
            pointHandler.sendEmptyMessage(3);
        }

    }

    /**
     * *************************************数据请求接收器*****************************************************************
     */
    private Handler pointSumHandler;
    private Handler transformerListHandler;
    private Handler pointHandler;

    /**
     * 项目详情信息接收器*
     */
    public static String s = "";

    private void addPointSumHandler() {
        pointSumHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                switch (msg.what) {
                    case HttpStringUtil.SUCCESSED:
                        if (FastJsonUtil.JsonToCheck((String) msg.obj)) {
                            bean = FastJsonUtil.JsonToGetPointSum((String) msg.obj);
                            SetFileUtil.setPointSumFile((String) msg.obj);
                            pointSumHandler.sendEmptyMessage(1);
                        }
                        break;
                    case 1:
                        s = "";
                        if (bean != null) {
                            s += "变压器:" + bean.trans_num + "台";
                            s += " 杆:" + bean.pole_num + "基";
                            s += " 用电户:" + bean.user_num + "户";
                            if (bean.route != null && bean.route.size() > 0) {
                                for (PointSumRouteBean b : bean.route) {
                                    String voltageGrade = DataUtil.getStringFormSystemTypeBean(HttpStringCodeTableUtil.voltageGrade, b.voltage_grade);
                                    if (voltageGrade.length() > 0) {
                                        try {
                                            if (b.line_length != null && b.line_length.length() > 0) {
                                                s += "\n" + voltageGrade + "线路:";
                                                s += b.line_length + "Km";
                                            }
                                            if (b.line_pole != null && b.line_pole.length() > 0) {
                                                s += " 杆塔:" + b.line_pole + " 基";
                                            }
                                        } catch (Exception e) {
                                        }
                                    }

                                }
                            }

                        }
                        words.setText(s);
                        break;
                    case HttpStringUtil.ERROR:
                        if (MyApp.isOnLine) {
                            ToastShow.showShort(mActivity, (String) msg.obj);
                        }
                        break;

                }
            }
        };
    }

    /**
     * 项目台区信息接收器*
     */
    private void addTransformerListHandler() {
        transformerListHandler = new Handler() {
            List<Exploration> DATA;

            @Override
            public void handleMessage(Message msg) {
                switch (msg.what) {
                    case HttpStringUtil.SUCCESSED:
                        if (FastJsonUtil.JsonToCheck((String) msg.obj)) {
                            DATA = FastJsonUtil.JsonToGetExplorationList((String) msg.obj);
                            SetFileUtil.setTransformerLis((String) msg.obj);
                            transformerListHandler.sendEmptyMessage(1);
                        }
                        break;
                    case 1:
                        bitTypeBeans.clear();
                        bitTypeBeans.add(new BitTypeBean("-1", "10KV", "10KV", pointType));
                        if (DATA != null && DATA.size() > 0) {
                            for (Exploration e : DATA) {
                                if ((e.getExploration_type() != null && e.getExploration_type().length() > 0
                                        && e.getExploration_type().equals(pointType))
                                        || ((e.getExploration_type() == null
                                        || e.getExploration_type().length() == 0)
                                        && e.getPoint_type().equals(pointType)))
                                    bitTypeBeans.add(new BitTypeBean(MString.getValueId(e.exploration_id, e.getUuid()), e.name, e.number, e.exploration_type));
                            }
                        }
                        break;
                    case 2:
                        DATA = transList;
                        transformerListHandler.sendEmptyMessage(1);
                        break;
                    case HttpStringUtil.ERROR:
                        ToastShow.showShort(mActivity, (String) msg.obj);
                        break;
                }
            }
        };
    }


    /**
     * 点位列表信息接收器*
     */
    List<Exploration> pointData;

    private void addPointHandler() {
        pointHandler = new Handler() {
            @Override
            public void handleMessage(Message msg) {
                switch (msg.what) {
                    case HttpStringUtil.SUCCESSED:
                        if (FastJsonUtil.JsonToCheck((String) msg.obj)) {
                            if (pointData == null) {
                                pointData = FastJsonUtil.JsonToGetExplorationList((String) msg.obj);
                            } else {
                                pointData.clear();
                                pointData.addAll(FastJsonUtil.JsonToGetExplorationList((String) msg.obj));
                            }
                            SetFileUtil.setExplorationList((String) msg.obj, pointType);
                            pointHandler.sendEmptyMessage(3);

                        } else {
                            ToastShow.showShort(mActivity, FastJsonUtil.JsonToCheck_String((String) msg.obj));
                        }
                        break;

                    case 3:
                        try {
                            List<Exploration> point = new ArrayList<>();
                            for (Exploration b : pointData) {
                                if (b.pt_type.equals(MString.DWD) && !b.getFlag().equals(MString.del)) {
                                    point.add(b);
                                }
                            }
                            pointData.clear();
                            pointData.addAll(point);
                            getTransformerList();
                        } catch (Exception e) {

                        }
                        pointHandler.sendEmptyMessage(1);
                        break;
                    case 1:
                        addPoint(pointData);
                        break;
                    case 2:
                        if (span) {
                            addSpan();
                        }

                        break;

                    case HttpStringUtil.ERROR:
                        ToastShow.showShort(mActivity, (String) msg.obj);
                        break;

                }
            }
        };
    }


    /**
     * 加载点位并画出线段*
     */
    boolean flag = true;
    List<SpanBean> points = new ArrayList<>();

    private String pointType = "11";

    private void addPoint(final List<Exploration> pointData) {
        flag = true;
        mBaiduMap.clear();
        points.clear();
        baidumapstyle.clearmarker_Seconds();
        //没有点位的时候展示项目地址
        if (pointData == null || pointData.size() == 0) {
            if (currentPt == null) {
                try {
                    currentPt = new LatLng(Double.parseDouble(MyApp.currProject.getLat()), Double.parseDouble(MyApp.currProject.getLng()));
                } catch (Exception e) {
                    currentPt = null;
                    return;
                }
            }
            try {
                if (mBaiduMap != null) {
                    mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(new MapStatus.Builder().target(currentPt).zoom(MyApp.zoom).build()));
                    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(currentPt));//将位置设为中心点
                }
            } catch (Exception e) {
                return;
            }
        } else {
            //有点位的时候展示一个点位的位置
            try {
                currentPt = new LatLng(Double.parseDouble(pointData.get(0).getLat()), Double.parseDouble(pointData.get(0).getLng()));
            } catch (Exception e) {
                currentPt = null;
                return;
            }
            try {
                if (mBaiduMap != null) {
                    mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(new MapStatus.Builder().target(currentPt).zoom(MyApp.zoom).build()));
                    mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(currentPt));//将位置设为中心点
                }
            } catch (Exception e) {
                return;
            }
        }
        baidumapstyle.projectType = pointType;
        try {
            baidumapstyle.setPointClick(1);
            new Thread(new Runnable() {
                @Override
                public void run() {
                    Map<String, Integer> map = DataUtil.getIconData(0);
                    try {
                        for (Exploration exploration : pointData) {
                            if (exploration.lat != null && exploration.lng != null && exploration.lat.length() > 0 && exploration.lng.length() > 0) {
                                LatLng point = new LatLng(Double.parseDouble(exploration.lat), Double.parseDouble(exploration.lng));
                                if (corner) {
                                    baidumapstyle.addMarka(exploration, ProjectMapActivity.this, point, Integer.parseInt(map.get(exploration.pt_id).toString()));
                                } else {
                                    baidumapstyle.addMarka(exploration, point, Integer.parseInt(map.get(exploration.pt_id).toString()));
                                }
                                if (exploration.before_lat != null && exploration.before_lng != null && exploration.before_lat.length() > 0 && exploration.before_lng.length() > 0) {
                                    LatLng p1 = new LatLng(Double.parseDouble(exploration.lat), Double.parseDouble(exploration.lng));
                                    LatLng p2 = new LatLng(Double.parseDouble(exploration.before_lat), Double.parseDouble(exploration.before_lng));
                                    points.add(new SpanBean(new LatLng((p1.latitude + p2.latitude) / 2, (p1.longitude + p2.longitude) / 2), exploration.distance));
                                    MyLog.L(MString.SUCCESSED + " 档距add=" + " lat=" + Double.parseDouble(exploration.lat) + " lng=" + Double.parseDouble(exploration.lng));
                                    List<LatLng> points = new ArrayList<LatLng>();
                                    points.add(p1);
                                    points.add(p2);
                                    OverlayOptions ooPolyline = new PolylineOptions().width(10)
                                            .color(R.color.red).points(points);
                                    Polyline mPolyline = (Polyline) mBaiduMap.addOverlay(ooPolyline);
                                }
                            }
                        }
                        pointHandler.sendEmptyMessage(2);
                    } catch (Exception e) {
                    }

                }
            }).start();

        } catch (Exception e) {
        }

    }

    /****************************************地图设置******************************************************************/
    /**
     * 显示与隐藏按钮*
     */
    public void disPlay(View view) {
        LinearLayout setpoint_inf_item = (LinearLayout) findViewById(R.id.projectmap_inf_item);
        if (setpoint_inf_item.getVisibility() == View.VISIBLE) {
            setpoint_inf_item.setVisibility(View.GONE);
            ((SimpleDraweeView) view).setImageURI(UriUtil.getUri(MString.LOCALIMAGEHEAD + R.mipmap.fold));
        } else {
            setpoint_inf_item.setVisibility(View.VISIBLE);
            ((SimpleDraweeView) view).setImageURI(UriUtil.getUri(MString.LOCALIMAGEHEAD + R.mipmap.unfold));
        }
    }

    /**
     * 设置地图*
     */
    public MapView mMapView;
    public BaiduMap mBaiduMap;
    public MBaiduMap baidumapstyle;
    public static LatLng currentPt;//选定的点位

    private void findViewAndInit_MapButton() {
        /***档距与转角**/
        check_span = (SimpleDraweeView) findViewById(R.id.check_span);
        check_corner = (SimpleDraweeView) findViewById(R.id.check_corner);
        /***右上方拆旧**/
        baidumapstyle = (MBaiduMap) findViewById(R.id.baidumapstyle);
        baidumapstyle.setIsNewBlude();
        mMapView = baidumapstyle.getMapView();
        mBaiduMap = baidumapstyle.getBaiduMap();
        baidumapstyle.hidePosition();

        if (currentPt == null) return;
        try {
            baidumapstyle.setMarka(currentPt);
            mBaiduMap.animateMapStatus(MapStatusUpdateFactory.newMapStatus(new MapStatus.Builder().target(currentPt).zoom(MyApp.zoom).build()));
            mBaiduMap.setMapStatus(MapStatusUpdateFactory.newLatLng(currentPt));//将位置设为中心点
        } catch (Exception e) {
        }

    }

    /**
     * 设置界面基础ui*
     */
    private void findViewAndInit_UI() {
        TextView reconnaissanceButton = (TextView) findViewById(R.id.projectmap_bottom_reconnaissancebutton);
        TextView code = (TextView) findViewById(R.id.projectmap_bottom_code);
        TextView detailedButton = (TextView) findViewById(R.id.projectmap_bottom_detailedbutton);
        SetTypeface.set(reconnaissanceButton, IconSourse.TASHE);
        SetTypeface.set(detailedButton, IconSourse.DETAILED);
        SetTypeface.set(code, IconSourse.CODE);
        reconnaissanceButton.append(" 点位采集");
        detailedButton.append(" 查看明细");

        if (MyApp.ReadOnly) {
            reconnaissanceButton.setBackgroundResource(R.drawable.inputbox_gray_4);
        }
        /**台区**/
        RelativeLayout pop_button = (RelativeLayout) findViewById(R.id.projectmap_pop);
        final RelativeLayout pop_bottom = (RelativeLayout) findViewById(R.id.projectmap_pop_bottom);
        TextView pop_right = (TextView) findViewById(R.id.projectmap_pop_right);
        TextView pop_title = (TextView) findViewById(R.id.projectmap_pop_title);
        pop_title.setText("台区");
        SetTypeface.set(pop_right, IconSourse.DROPDOWN);
        pop_button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                if (bitTypeBeans.size() == 0) {
                    ToastShow.showShort(mActivity, "暂无台区！");
                    return;
                }
                PopwindowUtil.openProjectMapPop(view, pop_bottom, mActivity, bitTypeBeans, projectName);
            }
        });
    }


    /**
     * 设置数据控件*
     */
    private void findView_Data() {
        TextView bottom_title = (TextView) findViewById(R.id.projectmap_bottom_title);
        TextView bottom_lbutton = (TextView) findViewById(R.id.projectmap_bottom_lbutton);
        words = (TextView) findViewById(R.id.projectmap_bottom_words1);
        words.setMovementMethod(ScrollingMovementMethod.getInstance());
        bottom_title.setText(projectName);
        bottom_lbutton.setText(stage);
    }


    private String getDesignStage(String code) {
        List<SystemTypeBean> designStage = FastJsonUtil.JsonToData_Code(HttpStringCodeTableUtil.designStage);//设计阶段
        for (SystemTypeBean s : designStage) {
            if (s.getTypecode().equals(code)) {
                return s.getTypename() + "阶段";
            }
        }
        return "";
    }


    //点位采集
    public void Reconnaissance(View v) {
        if (MyApp.ReadOnly) {
        } else {
            IntentToActivity.intent(mActivity, ReconnaissanceActivity.class);
        }
    }

    //查看项目明细
    public void details(View v) {
        Bundle bundle = new Bundle();
        bundle.putString(MString.TextTYPE, "0");
        bundle.putString(MString.exploration_type, pointType);
        IntentToActivity.intent(mActivity, ProjectDetailsActivity.class, bundle);

    }

    /**
     * 新建与拆旧*
     */
    boolean buldeflag = true;

    public void isnewlyBuild(View v) {
        if (buldeflag) {
            //新建
            buldeflag = false;
            getExplorationList("11");

        } else {
            //拆旧
            buldeflag = true;
            getExplorationList("12");
        }

    }


    /**
     * 档距与转角*
     */
    SimpleDraweeView check_span, check_corner;
    boolean span = false;
    boolean corner = false;

    //档距
    public void span(View v) {
        if (span) {
            span = false;
            check_span.setImageURI(UriUtil.getUri(MString.LOCALIMAGEHEAD + R.mipmap.displayspan));
            addPoint(pointData);
            MyLog.L(MString.SUCCESSED + " 档距span=" + span);
        } else {
            span = true;
            check_span.setImageURI(UriUtil.getUri(MString.LOCALIMAGEHEAD + R.mipmap.hiddenspan));
            addSpan();
        }
    }

    private void addSpan() {
        MyLog.L(MString.SUCCESSED + " 档距points=" + JSON.toJSONString(points));
        MyLog.L(MString.SUCCESSED + " 档距span=" + span);
        if (points.size() > 0) {
            for (SpanBean s : points) {
                if (!(s.distance == null || s.distance.length() == 0)) {
                    baidumapstyle.addMarka(mActivity, s.distance, s.point);
                }

            }
        }
    }

    //转角
    public void corner(View v) {
        if (corner) {
            corner = false;
            check_corner.setImageURI(UriUtil.getUri(MString.LOCALIMAGEHEAD + R.mipmap.displaycorner));
            addPoint(pointData);
        } else {
            corner = true;
            check_corner.setImageURI(UriUtil.getUri(MString.LOCALIMAGEHEAD + R.mipmap.hiddencorner));
            addPoint(pointData);
        }

    }

}
